import java.util.Scanner;

public class TestMain2 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int q = scanner.nextInt();
        int[] arr = new int[n + 1];
        for(int i = 1; i < n+1; i++) {
            arr[i] = scanner.nextInt();
        }
        long[] dp = new long[n + 1];
        for(int i = 1; i < n + 1; i++) {
            dp[i] = dp[i - 1] + arr[i];
        }
        while(q > 0) {
            int l = scanner.nextInt();
            int r = scanner.nextInt();
            System.out.println(dp[r] - dp[l - 1]);
            q--;
        }
    }
}
